import Layout from "@/layout/index.vue";
import PlayLayout from "@/layout/play.vue";
import {createRouter, createWebHashHistory, RouteRecordRaw} from "vue-router";

const routes: RouteRecordRaw[] = [
    {
        path: "/",
        component: Layout,
        meta: {title: "首页"},
        children: [
            {
                path: "",
                name: "home",
                component: () => import("@/views/home/index.vue")
            }
        ]
    },
    {
        path: "/welcome",
        meta: {title: "welcome"},
        component: () => import("@/views/welcome/index.vue")
    },
    {
        path: "/play",
        component: PlayLayout,
        meta: {title: "播放中·"},
        children: [
            {
                path: "",
                name: "play",
                component: () => import("@/views/play/index.vue")
            }
        ]
    }
];

const router = createRouter({
    history: createWebHashHistory(),
    routes
});

router.beforeEach((to, from, next) => {
    document.title = to.meta.title;
    next();
})
export default router;
